package com.zixi.ai.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求方式
 * @author mqiqe
 */
public enum HttpMethod {
    // 操作
    GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;

    private static final Map<String, HttpMethod> MAPPINGS = new HashMap<>(16);

    static {
        for (HttpMethod httpMethod : values()) {
            MAPPINGS.put(httpMethod.name(), httpMethod);
        }
    }

    public static HttpMethod resolve( String method) {
        return (method != null ? MAPPINGS.get(method) : null);
    }

    public boolean matches(String method) {
        return (this == resolve(method));
    }
}
